import React, { Component } from 'react'
import { inject, observer } from 'mobx-react';
import { Link, hashHistory } from 'react-router';
import { InputItem, Button, Toast, WhiteSpace, WingBlank } from 'antd-mobile'
import { createForm } from 'rc-form';
import cookie from 'react-cookie'
import Ajax from 'lib/Ajax'
import Top from 'components/top'

const pageName = 'register';

@inject('languageStore')
@observer
class ModuleName extends Component {
	constructor(props) {
    super(props);
    this.state = {

    }
  }

  componentDidMount(){

  }

  register = () => {
		const self = this;
		Ajax({
      url: '/teacher/register',
      data: self.props.form.getFieldsValue(),
      success: function(result){
				Toast.info('注册成功');
				hashHistory.push('/daoshi/login');
      },
      error: function(error){
        Toast.info(error||'请求失败');
      }
    });
  }

  render() {
		const { getFieldProps } = this.props.form;
		const pageData = this.props.languageStore.getPageData(pageName);
		pageName
    return (
    	<div className={pageName}>
				<Top
					title="导师注册"
				/>
				<div style={{padding: '90px 50px 0'}}>
					<div style={{paddingRight: 30}}>
						<InputItem
							{...getFieldProps('account')}
							placeholder=""
						>
							<i className="iconfont icon-wo"></i>
						</InputItem>
						<InputItem
							{...getFieldProps('pwd')}
							placeholder=""
						>
							<i className="iconfont icon-mima"></i>
						</InputItem>
					</div>
					<WhiteSpace size="lg" />
					<WingBlank size="lg">
						<Button className="btn" style={{marginTop: 40}} type="primary" onClick={this.register}>注册</Button>
					</WingBlank>
				</div>
    	</div>
    )
  }
}

module.exports = createForm()(ModuleName)
